// 防抖函数封装
const debounce = (fn, delay = 300) => {
  let timer = null;
  return function (...args) {
    if (timer) clearTimeout(timer); //清除之前的延迟调用
    timer = setTimeout(() => {
      fn.apply(this.args); //延迟执行
    }, delay);
  };
};

export { debounce };
